package com.share.all.rest;

import com.share.all.model.City;
import com.share.all.service.CityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author caifan
 * @since 2023/2/3
 */
@Slf4j
@RestController
@RequestMapping("/city")
public class CityRest {

    @Autowired
    private CityService cityService;

    @GetMapping("/all")
    public List<City> allCity() {
        log.info("all city test");
        return cityService.allCity();
    }

    @PostMapping("/save")
    public void save(@RequestBody City city) {
        cityService.saveCity(city);
    }

    @GetMapping("/get")
    public City get(@RequestParam Long id) {
        return cityService.getById(id);
    }
}
